﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SDT.DataService.Repositories;
using SDT.Libraries.Utilities;
using SDT.DataService.Contexts;

namespace SDT.DataService.Services
{
    public class News_CategoryService : IService<Spider_Category_News>
    {
        #region Field

        private IRepository<Spider_Category_News> repository;
        #endregion

        #region Constructor
        public News_CategoryService()
            : this(new Repository<Spider_Category_News>())
        {
        }

        public News_CategoryService(IRepository<Spider_Category_News> repository)
        {
            this.repository = repository;

        }
        #endregion

       

        public int InsertCategory(int cid,int siteid, string name)
        {
            News_CategoryContext contextObj = new News_CategoryContext();
            try
            {
                return contextObj.InsertCategory (cid,siteid, name);
            }
            catch (Exception ex)
            {
                new LogException().Write(string.Format("  Module {0} --Msg {1} ", "CategoryService.InsertCategory", ex.Message));

            }
            finally { contextObj.Dispose(); }
            return 0;
        }

        public int UpdateCategory(int cateid, string name)
        {
            News_CategoryContext contextObj = new News_CategoryContext();
            try
            {
                return contextObj.UpdateCategory(cateid, name);
            }
            catch (Exception ex)
            {
                new LogException().Write(string.Format("  Module {0} --Msg {1} ", "NewsService.GetContentByPageID", ex.Message));

            }
            finally { contextObj.Dispose(); }
            return 0;
        }
        public IQueryable<Spider_Category_News> GetAll()
        {
            return repository.GetAll();
        }

        public bool Update(Spider_Category_News entity)
        {
            throw new NotImplementedException();
        }

        public bool Create(Spider_Category_News entity)
        {
            throw new NotImplementedException();
        }

        public bool Delete(Spider_Category_News entity)
        {
            throw new NotImplementedException();
        }
    }
}